package com.java.learning.cha1;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamDemo {
    public static void main(String[] args) {
        try (ObjectOutputStream obs = new ObjectOutputStream(new FileOutputStream("D:\\PersonObject.txt"))){
            Person person = new Person("张三",25,"上海");
            obs.writeObject(person);
            obs.flush();
            System.out.println("序列化完毕");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
